package design.simdi.code.final_paper.utils;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.wizard.IWizard;
import org.apache.wicket.markup.html.form.Form;

import design.simdi.code.final_paper.site.panels.MyWizard;

/**
 * 
 * @author Marius Dumitriu - (Jun 26, 2010 - 2:15:42 PM)
 * 
 */
public class AjaxPreviousButton extends WizardAjaxButton {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public AjaxPreviousButton(String id, IWizard wizard, Form<?> form) {
		super(id, wizard, form, "org.apache.wicket.extensions.wizard.previous");
		setDefaultFormProcessing(false);
	}

	@Override
	public final boolean isEnabled() {
		return getWizardModel().isPreviousAvailable();
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void onClick(AjaxRequestTarget target, Form form) {
		getWizardModel().previous();
		onPrevious(target);
	}

	public void onPrevious(AjaxRequestTarget target) {

	}

	protected void onError(final AjaxRequestTarget target, Form<?> form) {

		target.addComponent(findParent(MyWizard.class));

	}
}
